import * as types from '../Commom/ActionConst';
const initialState = {
    Citys: [],
    imageIndex: 0,
    city: '',
    area: '',
    town: '',
    countryHomeResult: '',

};

let RuralLibraryReducer = (state = initialState, action) => {
    switch (action.type) {
        case types.CurrentCity:
            return {
                ...state,
                ...action
            };
        case types.CurrentArea:
            return {
                ...state,
                ...action
            };
        case types.CurrentTown:
            return {
                ...state,
                ...action
            };
        case types.kCityList:
            return {
                ...state,
                ...action
            };
        case types.kCityListReceived:
            if (action.result != null) {
                return Object.assign({}, state, {
                    Citys: action.result.citys,
                });
            } else {
                return Object.assign({}, state, {
                    Citys: [],
                });
            }
        case types.kCollectionImgReceived:
            return Object.assign({}, state, {
                imageIndex: action.index,
            });
            break;
        case types.CountryHomeResult:
            return Object.assign({}, state, {
                countryHomeResult: action.result,
            });
        default:
            return state;
    }
};

export default RuralLibraryReducer;